<?
include("session.php");
if($_SESSION['user_flag'] != "admin") {
	exit; // 只用管理员才能给用户充值
}
$user_id = $_GET['user_id'];
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../webkit/utils/jquery.js"></script>
<script type="text/javascript" src="../webkit/utils/form.checker.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/> 
<body  bgcolor="#f4f4f4" style="margin:0px;" scroll=no>

<form name=f> 
<hr size=1>
<table width=100% cellspacing=1 cellpadding=3 align=center> 
	<tr>
        <td align=right nowrap>用户名称</td><td><span id="user_name" style="color:blue;">loading..</span></td>  
	</tr>
	<tr id="call_type_2">
		<td align=right>充值单价</td><td><input type='text' id="charge_price" class='input' check='numeric' warning='充值单价必须为数值！' 
		value="0.15" style="width:260px;color:red"><font color=gray>(元)</font></td>
	</tr>
	<tr id="call_type_2">
		<td align=right>充值条数</td><td><input type='text' id="charge_count" class='input' check='integer' warning='充值条数必须为整数！' 
		value="10000" style="width:260px;color:red"><font color=gray>(条)</font></td>
	</tr>
	<tr>
		<td align=right>备　　注</td><td><textarea style="width:280px;" rows=5 id="charge_desc"></textarea></td>
	</tr>
	<input type='hidden' id="user_id" value="<?echo $_GET['user_id']?>">
</form>	

<table width=100% cellspacing=1 cellpadding=3>
	<tr>
		<td align=center>
		<hr size=1>
		<input type="button" id="btn_save" class="button" value="确认充值" onclick="save()" disabled>　　<input type="button" class="button" value="关闭窗口" onclick="parent.closeDlg()"></td>
	</tr>
</table>

<script type="text/javascript">
	var op = "<?echo $_GET['op']?>";
	var f = document.f;
	function save() { 
		if(FormChecker.doCheck(f)) {
			var params = {};
			var els = f.elements;
			for(var i=0; i<els.length; i++) {
				if(els[i].type == "button" || els[i].type == "submit") continue;
				params[els[i].id] = els[i].value;
			}
			if(confirm("确定要为用户[ "+current_user_name+" ]充值[ "+$('#charge_count').val()+" ]条可呼记录吗？")) {
				$('#btn_save').attr('disabled', true);
				$.post("money_query.php?action=do_charge", params, function(data) {
					$('#btn_save').attr('disabled', false);
					if(data.indexOf("ok") == 0) {
						alert("用户充值成功!");
						parent.refreshGrid();
						parent.closeDlg();
					} else {  
						alert(data);
					}
				});
			}
		}
	}; 

	
	var current_user_name = "";

	$(function() {
		$.get("user_query.php?action=get&id=<?echo $user_id?>", function(data) {
			eval("var row = "+data);
			current_user_name = row['true_name'];
            $('#user_name').html(current_user_name);
			$('#btn_save').attr('disabled', false);
		});
	});
</script>
</body>
</html>